using System;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using TrainingWorkshop.MVPWebsite.User.Interface.Services;
using DataContracts;
using System.Collections.Generic;


namespace TrainingWorkshop.MVPWebsite.User
{
    public class UserController : IUserController
    {
        public UserController()
        {
        }
        private IUserService _userservice;
        [InjectionConstructor]
        public UserController
        ([ServiceDependency] IUserService userservice)
        {
            _userservice = userservice;
 
        }


        /// <summary>
        ///  Save a New User
        /// </summary>
        /// <param name="userDTO"></param>
        /// <returns></returns>
        public virtual bool AddNewUser(UserDTO userDTO)
        {
            return _userservice.AddNewUser(userDTO);
        }

        /// <summary>
        /// Delete User
        /// </summary>
        /// <param name="userId"></param>
        public virtual void DeleteUser(int userId)
        {
             _userservice.DeleteUser(userId);
        }

        /// <summary>
        /// Update User
        /// </summary>
        /// <param name="userDTO"></param>
        public virtual void UpdateUser(UserDTO userDTO)
        {
            _userservice.UpdateUser(userDTO);
        }

        /// <summary>
        /// Get All User
        /// </summary>
        /// <returns></returns>
        public virtual List<UserDTO> GetAllUser()
        {
            return _userservice.GetAllUser();
        }

        /// <summary>
        /// Get All Department
        /// </summary>
        /// <returns></returns>
        public virtual List<DepartmentDTO> GetAllDepartment()
        {
            return _userservice.GetAllDepartment();
        }

        /// <summary>
        /// Get User by Current UserId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public virtual UserDTO GetUserById(int userId)
        {
            return _userservice.GetUserById(userId);
        }

        /// <summary>
        /// Search User by Complex Conditions
        /// </summary>
        /// <param name="departmentId"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <returns></returns>
        public virtual List<UserDTO> SearchUser(int departmentId, string firstName, string lastName)
        {
            return _userservice.SearchUser(departmentId, firstName, lastName);
        }

        /// <summary>
        /// Get All User Role
        /// </summary>
        /// <returns></returns>
        public virtual List<RoleDTO> GetAllUserRole()
        {
            return _userservice.GetAllUserRole();
        }
    }
}
